from api.base_api.base_api import BaseApi
from api.base_api.select_car import SelectCar
from api.base_api.supported_cities import SupportedCities
import random


class CarEstimate(BaseApi):
    supported_cities_url = 'http://192.168.1.141:8001/car-estimate'

    def car_estimate(self, mobile, purpose):
        # 选择城市
        select_car = SelectCar().select_car()
        car_brand = select_car[0]
        car_series = select_car[1]
        car_type = select_car[2]
        trim_id = select_car[3]
        city_code = SupportedCities().supported_cities()[0]
        city_name = SupportedCities().supported_cities()[1]
        registration_time = '2017-01-01'
        mileage = (random.randint(0,100))*10000

        payload = {
            "user_mobile": mobile,
            "car_brand": car_brand,
            "car_series": car_series,
            "car_type": car_type,
            "registration_time": registration_time,
            "mileage": mileage,
            "city": city_name,
            "trim_id": trim_id,
            "city_id": city_code,
            "purpose": purpose
        }
        return payload

